<!DOCTYPE html>
<html lang="en">
<!--注意：引入thymeleaf的名称空间-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>SB Admin 2 - Bootstrap Admin Theme</title>

    <!-- Bootstrap Core CSS -->
    <link th:href="@{/vendor/bootstrap/css/bootstrap.min.css}" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link th:href="@{/vendor/metisMenu/metisMenu.min.css}" rel="stylesheet">

    <!-- Custom CSS -->
    <link th:href="@{/dist/css/sb-admin-2.css}" rel="stylesheet">

    <!-- Custom Fonts -->
    <link th:href="@{/vendor/font-awesome/css/font-awesome.min.css}" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <div class="login-panel panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Please Sign In</h3>
                    </div>
                    <div class="panel-body">
                        <form action="user/login.do" method="post" onsubmit="return subLogin()">
                            <fieldset>
                                <div class="form-group">
                                    <input class="form-control" placeholder="E-mail" name="uname" id="uname" type="text" autofocus>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" placeholder="Password" name="upass" id="upass" type="password">
                                </div>
                                <div class="checkbox">
                                    <label>
                                        <input name="remember" type="checkbox" value="Remember Me">Remember Me
                                    </label>
                                </div>
                                <!-- Change this to a button or input when using this as a form -->
                                <button class="btn btn-lg btn-success btn-block" >Login</button>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- jQuery -->
    <script th:src="@{/vendor/jquery/jquery.min.js}"></script>
    <script type="text/javascript">
        function subLogin() {
            var unameL = document.getElementById("uname");
            var upassL = document.getElementById("upass");
            if(unameL == null || unameL.value == ""){
                alert("账号不能为空！");
                return false;
            }
            if(upassL == null || upassL.value == ""){
                alert("密码不能为空！")
                return false;
            }
            return true;
        }
        function subRegister() {
            var uname = document.getElementById("uname");
            var upass1 = document.getElementById("upass1");
            var upass2 = document.getElementById("upass2");
            var uphone = document.getElementById("uphone");
            var ucdkey = document.getElementById("ucdkey");
            var unickName = document.getElementById("unickName");
            if(uname == null || uname.value == ""){
                alert("账号不能为空！");
                return false;
            }
            if(upass1 == null || upass1.value == ""){
                alert("密码不能为空！");
                return false;
            }
            if(upass1.value != upass2.value){
                alert("两次输入的密码不一致！");
                return false;
            }
            if(unickName.value == "" || unickName == null){
                alert("昵称不能为空！");
                return false;
            }
            if(uphone.value == "" || uphone == null){
                alert("联系方式不能为空！")
                return false;
            }
            if(ucdkey.value == "" || ucdkey == null){
                alert("邀请码不能为空！")
                return false;
            }
            return true;
        }

        function getdistrict(){
            $.ajax({
                url:'${ctx }/selectAllDistrict.do',
                dataType :'json',
                type :'POST',
                success : function(reqs) {
                    var json = reqs;
                    console.log(json.length)
                    var option;
                    for(var i=0;i<json.length;i++){
                        console.log(json[i].district_id)
                        option += '<option value='+json[i].district_id +'>' + json[i].district_name + '</option>';
                    }
                    $("#setDistrict").append('<option value=0 selected>'+'请选择管区'+'</option>'+option);
                    //获取选择的 管区id
                    //调用根据管区id查询站信息的函数getdistrictId
                }
            })
        }

        function getstation(district_id){
            console.log("进入请求站信息的函数"+district_id);
            $.ajax({
                url:'${ctx }/selectByDistrictIdStation.do',
                dataType :'json',
                data: {'district_id':district_id},
                type :'POST',
                success : function(reqs) {
                    var option;
                    for(var i=0;i<reqs.length;i++){
                        option += '<option value='+reqs[i].station_id +'>' + reqs[i].station_name + '</option>';
                    }
                    $("#setstation").append('<option value=0 selected>'+'请选择站区'+'</option>'+option);
                }
            })
        }
        function getdistrictId(){
            var setDistrict = document.getElementById('setDistrict');
            var inx = setDistrict.selectedIndex;
            var op = setDistrict.options[inx];
            var district_id = op.value;
            getstation(district_id);
        }
        //动态查询用户账号是否已经存在
        function selectUserUname(){
            /* alert(uname); */
            var getuname = document.getElementById('uname');
            console.log("动态查询用户账号是否已经存在"+getuname.value);
            $.ajax({
                url:'${ctx }/selectUserByuname.do',
                dataType :'json',
                data: {'uname':getuname.value},
                type :'POST',
                success : function(reqs) {
                    console.log(reqs);
                    if(reqs == true){

                    }
                }
            })
        }
    </script>
    <!-- Bootstrap Core JavaScript -->
    <script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script th:src="@{/vendor/metisMenu/metisMenu.min.js}"></script>

    <!-- Custom Theme JavaScript -->
    <script th:src="@{/dist/js/sb-admin-2.js}"></script>

</body>

</html>
